package com.droolsBoot.util;

/**
 * describe:
 *
 * @author laizhihui
 * @date 2018/04/25
 */
public class LossMoneyTemplate {
    /**
     * 该类是一个模板工具类
     * 通过参数可以生成规则内容
     * {"condition":{},"rule":{"name":"优惠券30元"},"action":{"money":30.0}}
     *
     * 这是一个模板，可以根据 定义的内存结构，根据这个模板生成对应的规则
     *
     * 生成之后的规则:
     * package com.promote
     *
     * import	com.droolsBoot.model.RuleResult;
     * rule "???30?"
     * 	no-loop true
     * 		when
     * 		    $r:RuleResult(true)
     *  		then
     *            modify($r){
     *                 setPromoteName(drools.getRule().getName()),
     *                 setFinallyMoney($r.getMoneySum() - 30.0)
     *            }
     * end
     */
    public static final String workMoneyST = "wordImport(rules) ::=<<\n" +
            "package com.promote\n" +
            "\n" +
            "import\tcom.droolsBoot.model.RuleResult;\n" +
            "<rules; separator=\"\\n\\n\">\n" +
            ">>\n" +
            "\n" +
            "ruleValue(condition,action,rule) ::=<<\n" +
            "rule \"<rule.name>\"\n" +
            "\tno-loop true\n" +
            "\t\twhen\n" +
            "\t\t    $r:RuleResult(true)\n" +
            " \t\tthen\n" +
            "           modify($r){\n" +
            "                setPromoteName(drools.getRule().getName())<if(action)>,\n" +
            "                setFinallyMoney($r.getMoneySum() - <action.money><endif>)\n" +
            "           }\n" +
            "end\n" +
            ">>\n";
}
